package com.szeldon.declatest.scenario.declaration;

import java.util.List;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.szeldon.declatest.declaration.scenario.ScenarioDeclaration;
import com.szeldon.declatest.declaration.scenario.parts.ElsePartDeclaration;
import com.szeldon.declatest.declaration.scenario.parts.IfPartDeclaration;
import com.szeldon.declatest.declaration.scenario.parts.ScenarioPartDeclaration;
import com.szeldon.declatest.declaration.scenario.parts.ScenarioPartsTypeEnum;
import com.szeldon.declatest.declaration.scenario.parts.DoScenarioStepPartDeclaration;

/**
 * Tests for {@link ScenarioDeclaration} class.
 * 
 * @author szeldon
 * 
 */
public class ScenarioDeclarationTest {
    @Test
    public void testGoodScenario() {

        ScenarioDeclaration scenario = new ScenarioDeclaration("some-id", "scenario description");
        ScenarioPartDeclaration if0 = new IfPartDeclaration("left", "operator", "right", "description");
        if0.addSubpart(new DoScenarioStepPartDeclaration("some-stepId"));
        scenario.addScenarioPart(if0);
        scenario.addScenarioPart(new ElsePartDeclaration("left", "operator", "right", "description"));
        scenario.addScenarioPart(new ElsePartDeclaration("left", "operator", "right", "description"));

        List<ScenarioPartDeclaration> partsList = scenario.getPartsList();

        ScenarioPartDeclaration part0 = partsList.get(0);
        ScenarioPartDeclaration part1 = partsList.get(1);
        ScenarioPartDeclaration part2 = partsList.get(2);

        ScenarioPartDeclaration subpart0 = part0.getSubpartsList().get(0);

        Assert.assertEquals(part0.getPartType(), ScenarioPartsTypeEnum.IF_PART);
        Assert.assertEquals(part1.getPartType(), ScenarioPartsTypeEnum.ELSE_PART);
        Assert.assertEquals(part2.getPartType(), ScenarioPartsTypeEnum.ELSE_PART);

        Assert.assertEquals(subpart0.getPartType(), ScenarioPartsTypeEnum.DO_SCENARIO_STEP_PART);
    }

}
